﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using LightweightControls;

namespace CSharpLightWeightControls
{
    public class RoundButton : LightweightControl
    {
        public string Text = "";

        public override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            BackColor = Color.Red;
            Invalidate();
        }

        public override void OnClick(EventArgs e)
        {
            base.OnClick(e);
            Position = new Point(Position.X, Position.Y + 10);
            Invalidate();
        }

        public override void OnPaint(PaintEventArgs e)
        {
            var g = e.Graphics;
            using (var b = new SolidBrush(Color.FromArgb(40, BackColor)))
            {
                g.FillEllipse(b, e.ClipRectangle);
                g.DrawEllipse(Pens.Black, e.ClipRectangle);
                var sf = new StringFormat();
                sf.Alignment = StringAlignment.Center;
                sf.LineAlignment = StringAlignment.Center;
                g.DrawString(Text, Font, Brushes.Black, new RectangleF(e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.Width, e.ClipRectangle.Height), sf);
            }
        }
    }

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            var lc = new LightweightContainer();
            var lb = new LightweightButton();
            var rb = new RoundButton();
            var rb2 = new RoundButton();
            lc.Dock = DockStyle.Fill;
            lb.Position = new Point(0, 0);
            lb.Text = "Hello World";
            lc.BackColor = Color.AliceBlue;
            lc.Add(lb);
            rb.Position = new Point(0, 100);
            rb.Size = new Size(50, 50);
            rb.Text = "Hello with very long text";
            lc.Add(rb);
            rb2.Position = new Point(0, 110);
            rb2.Size = new Size(50, 50);
            rb2.Text = "Hello 2";
            lc.Add(rb2);
            this.Controls.Add(lc);
        }
    }
}
